#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
	int n = 0;
	scanf("%d", &n);
	getchar();
	int arr[10000][3] = { 0 };
	for (int x = 1; x <= n; x++)
	{
		for (int y = 0; y <= 2; y++)
			scanf("%d", &arr[x][y]);
		getchar();
	}
	int dui = 0;
		for (int x = 1; x <= n; x++)
		{
			int all1 = arr[x][0] + arr[x][1] + arr[x][2];
			for (int m = x; m <= n; m++)
			{
				if (x == m)continue;
				int all2 = arr[m][0] + arr[m][1] + arr[m][2];
				int k = 0;
				if (-10 <= all1 - all2 && all1 - all2 <= 10)
				{
					for (int u = 2; u >= 0; u--)
						if (-5 <= arr[x][u] - arr[m][u] && arr[x][u] - arr[m][u] <= 5)
							k++;
					if (k == 3)dui++;
				}
			}
		}
	printf("%d", dui);
	return 0;
}